﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using GrayParrot.Web.Controls;
using GrayParrot.Core.Filters;
using FimetContoDeposito.DAL;

namespace FimetContoDeposito.BLL.ResultSets
{
	public class UnitaDiMisuraResultSet : ResultSet<FCD_UnitaDiMisura>
	{
        public UnitaDiMisuraResultSet(DTParameters param, IQueryable<FCD_UnitaDiMisura> result)
            : base(param, result)
        {
        }

        public override Expression<Func<FCD_UnitaDiMisura, bool>> ApplyGeneralFilter(string searchPattern)
        {
            var predicate = PredicateBuilder.False<FCD_UnitaDiMisura>();

            if (!string.IsNullOrWhiteSpace(searchPattern))
            {
                predicate = predicate.Or(im => im.Descrizione != null && im.Descrizione.Contains(searchPattern));
            }

            return predicate;
        }

        public override Expression<Func<FCD_UnitaDiMisura, bool>> ApplyGeneralColumnsFilter(List<string> columnSearch)
        {
            var predicate = PredicateBuilder.True<FCD_UnitaDiMisura>();

            string m_codice = columnSearch[ColumnIndex];
            string m_descrizione = columnSearch[ColumnIndex];

            if (!string.IsNullOrWhiteSpace(m_descrizione))
            {
                predicate = predicate.And(im => im.Descrizione.Contains(m_descrizione));
            }

            return predicate;
        }
	}
}
